<?php
	

autoLoader();
// display( $_REQUEST );
// display( $_POST ); exit;

if( false == isset( $_POST['Submit'] ) || false == valStr( $_POST['name'] ) ) { 
	$str = '';
	$str .= '<form name=myform method=post action=modules.php?file=specialization&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
	$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
	echo $str;
	exit;
}

if( true == isset( $_POST['operation'] ) && 'insert' == strtolower( $_POST['operation'] ) ) {
	
	$objobjWardType 	= new BaseWardTypes();

	
	$objobjWardType->setName( $_POST['name'] );
	$objobjWardType->setDescription( $_POST['description'] );
	$objobjWardType->setWardCatagoryId( $_POST['ward_catagory_id'] );
	$objobjWardType->setIsPublished( $_POST['is_published'] );
	
	if( 1 == $objobjWardType->insert() ) {
		$str = '';
		$str .= '<form name=myform method=post action=modules.php?file=view_wards_type&type=view&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
		$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
		echo $str;
		exit;
	}
} else if( true == isset( $_POST['operation'] ) && 'update' == strtolower( $_POST['operation'] ) ) 
{
	$objWardTypes 	= new WardTypes();
	$objobjWardType 	= $objWardTypes->fetchWardTypesById( $_POST['ward_type_id'] );
	
	$objobjWardType->setId( $_POST['ward_type_id'] );
	
	if( true == valStr( $_POST['name'] ) ) {
		$objobjWardType->setName( $_POST['name'] );
	}
	
	if( true == valStr( $_POST['description'] ) ) {
		$objobjWardType->setDescription( $_POST['description'] );
	}
	
	if( true == valStr( $_POST['ward_catagory_id'] ) ) {
		$objobjWardType->setWardCatagoryId( $_POST['ward_catagory_id'] );
	}
		
	if( true == valStr( $_POST['is_published'] ) ) {
		$objobjWardType->setIsPublished( $_POST['is_published'] );
	}
	
	if( 1 == $objobjWardType->update() ) {
		$str = '';
		$str .= '<form name=myform method=post action=modules.php?file=view_wards_type&type=view&mid=' . $_REQUEST['mid'] . '&smid=' . $_REQUEST['smid'] . '>';
		$str .= '<script language=JavaScript>document.myform.submit();</script></form>';
		echo $str;
		exit;
	}
}

?>